package be.idamf.profiler
{
	import flash.display.DisplayObject;
	import flash.events.Event;
	import flash.system.System;
	
	import mx.logging.ILogger;
	import mx.logging.Log;
	
	[Mixin]
	public class ProfilerLog
	{
		protected const LOG:ILogger = Log.getLogger("be.idamf.profiler");
		protected const GC:GarbageCollector = new GarbageCollector();
		
		protected var root:DisplayObject;
		
		public static function init(root:DisplayObject):void
		{
			new ProfilerLog(root);
		}
		
		public function ProfilerLog(root:DisplayObject):void
		{
			this.root = root;
			
			GC.addEventListener(Event.COMPLETE, gc_completeHandler);
		}
		
		protected function gc_completeHandler(event:Event):void
		{
			var mb:int = System.totalMemory / 1048576;
			
			LOG.info("Garbage Collection Complete");
			LOG.info("Total Memory: " + mb + "Mb");
		}
	}
}